/*******************************************************************************
 * Copyright (c) 2011 Technische Universität Darmstadt
 * 					  Fachbereich Informatik
 * 					  Theoretische Informatik - Kryptographie und Computeralgebra
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 ******************************************************************************/

var info = Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULAppInfo);

if(info.version.charAt(0)<5){
	Components.utils.import("resource://app/modules/gloda/utils.js"); //not tb5
}

if(info.version.charAt(0)>=5){
	Components.utils.import("resource://gre/modules/AddonManager.jsm"); //needed!
}

/**
 * Get the version of the extension
 */
function getVersion()
{
	const GUID = "CryptoBird@cdc.de";
	var nsIExtensionManager, version;
	if (info.version.charAt(0) < 5) {
		nsIExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
	} else  {
		AddonManager.getAddonByID(GUID, function(addon) {
			version = addon.version;
			document.getElementById("version").value = "Version: "+version;
		});
	}

	if (nsIExtensionManager){
		document.getElementById("version").value = "Version: "+nsIExtensionManager.getItemForID(GUID).version;
	} else {
		document.getElementById("version").value = "Version: "+version; // intendet!!!
	}
}